<%@ page language="java" import="java.util.*,com.ruohi.util.common.*" pageEncoding="UTF-8"%>
<%@page import="java.sql.Connection"%>
<%@page import="com.ruohi.util.dbutil.DBHelper"%>
<%@page import="com.ruohi.manage.PoolManager"%>
<%@page import="com.ruohi.manage.DBType"%><%
	String tableName = "gift_member_payoff";
	String tablePrefix = Env.getInstance().getProperty("table_prefix");
	String fileds = " * ";
	String channelUUID = CommonString.getFormatPara(request.getParameter("channel_uuid"));
	String whereStr = " ";
	String orderByStr = " add_date desc,id desc ";
	
	int today_new_member_count = 0;
	Connection conn = null;
	DBHelper dbHelper = DBHelper.getInstance();
	try{
		conn = PoolManager.getConnection(DBType.BUSINESS);
		today_new_member_count = CommonString.getFormatInt(dbHelper.getOne("select count(id) from gift_member_payoff where convert(varchar(20),add_date,23)=convert(varchar(20),getdate(),23)", conn));
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		DBHelper.freeConnection(conn);
	}

	
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><%=Env.getInstance().getProperty("project_name") %></title>
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
  </head>
  <body>
  	<div class="searchForm">
  		<div class="searchCondition">
  			<div class="searchList">
		  		<div class="searchLeft">用户名</div>
		  		<div class="searchRight">
		  			<input type="text" class="jr_text" name="mem_no" id="mem_no" />
		  		</div>
		  	</div>
		  	<div class="searchList" style="width:440px;">
		  		<div class="searchLeft">申请时间</div>
		  		<div class="searchRight" style="width:320px;">
		  			<input type="text" class="Wdate jr_text" style="width:120px;" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="add_date_start" id="add_date_start" />
		  			-
		  			<input type="text" class="Wdate jr_text" style="width:120px;" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="add_date_end" id="add_date_end" />
		  		</div>
		  	</div>
  		</div>
  		<div class="searchBtn">
  			<input type="button" class="btn" onclick="doSearch();" value="查询" /><input type="button" style="margin-left: 5px;" class="btn" onclick="doClearForm();" value="重置" />
  		</div>
  	</div>
  	<div style="clear: left;"></div>
  	
	<div class="l-loading" style="display: block" id="pageloading"></div> 
	<div id="maingrid" style="margin: 0; padding: 0"></div>
	<div style="display: none;"></div>
  </body>
</html>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/plugin/date/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js" prefix="<%=tablePrefix %>" type="text/javascript"></script>
<script type="text/javascript">
	var grid;
	var windowWidth = 800;
	var windowHeight = 420;
	var channelUUID = '<%=channelUUID %>';
	var tableName = "<%=tableName %>";
	var fields = "<%=fileds %>";
	var whereStr = "<%=whereStr %>";
	var orderBy = "<%=orderByStr %>";
	var columnsArr = [];
	var url = "";
	var conditionStr = "";
	var params = [];
	jQuery(function() {
		params.push({'name':'enumNo','value':'106013'});
		grid = new Dev21sunGrid({
			addToolbar:[{
				text : '提现申请(<%=today_new_member_count %>)',
				icon : 'config'
			}]
		});
		jQuery("#pageloading").hide();
	});
	var is_showData = [{ is_show : 1 , text: '是' }, { is_show : 0 , text: '否'}];
	//列数组
	columnsArr =  [ 
		{ display : '用户名', name : 'mem_no', align : 'left' , type : 'string' , width : 120, render:function(row){
			return "<a class='link' href='javascript:void(0);' onclick='addAndEdit("+row.__index+");'>"+row.mem_no+"</a>";
		} } ,
		{ display : '申请日期', name : 'add_date', align : 'center' , type : 'date' , width : 120 } ,
		{ display : '提现金额', name : 'payoff', align:'center', width:150, type:'string'},
		{ display:'状态', name:'order_status', align:'center', width:100, type:'string', render:function(row){
			var str = "";
			if(row.order_status==1){
				str="<span style='color:red;'>未处理</span>";
			}else if(row.order_status==2){
				str="<span style='color:blue;'>未通过</span>";
			}else if(row.order_status==100){
				str="已提现";
			}
			return str;
		} },
		{ display:"操作", align:"center", width:150, type:"int", render:function(row){
			return "<a href='javascript://void(0);' onclick='viewOrders(" + row.__index + ");'>查看提现订单</a>";
		} }
	];
	
	/*列表页条件查询*/
	function doSearch(){
		params = [];
		conditionStr = "";
		var mem_no = jQuery("#mem_no").val();
		if(''!=jQuery.trim(mem_no)){
			conditionStr += " and mem_no like '%"+mem_no+"%' ";
		}
		var nick_name = $.trim($("#nick_name").val());
		if(nick_name != ""){
			conditionStr += " and nick_name like '" + nick_name + "'";
		}
		var mem_name = jQuery("#mem_name").val();
		if(''!=jQuery.trim(mem_name)){
			conditionStr += " and mem_name like '%"+mem_name+"%' ";
		}
		var start_date = jQuery("#add_date_start").val();
		if(''!=jQuery.trim(start_date)){
			conditionStr += " and add_date > '"+start_date+"' ";
		}
		var end_date = jQuery("#add_date_end").val() ;
		if(''!=jQuery.trim(end_date)){
		    conditionStr += " and add_date < '"+end_date+"'" ;
		}
		var state = jQuery("#state").val();
		if(''!=jQuery.trim(state)){
			conditionStr += " and state = '"+state+"' ";
		}
		var brand = jQuery("#brand").val();
		if(''!=jQuery.trim(brand)){
			conditionStr += " and brand = '"+brand+"' ";
		}
		var type = $("#type").val();
		if($.trim(type)!=""){
			conditionStr += " and type='" + type + "'";
		}
		params.push({'name':'enumNo','value':'106013'});
		params.push({'name':'tableName','value':tableName});
		params.push({'name':'fields','value':fields});
		params.push({'name':'whereStr','value':whereStr+conditionStr});
		params.push({'name':'orderBy','value':orderBy});
		grid.options.parms=params;
		grid.loadData();
	}
	
	function addAndEdit(index){
    	if(undefined==index){//如果是增加
			toolbarAdd({
				width:800,
				height:350,
				folderName:"gift.21-sun.com/gift_member_payoff",
				fileName:"gift_member_payoff",
				params:{
					channel_uuid:'<%=channelUUID%>'
				},
				title:"增加"
			});
    	}else{//如果是修改
	    	var row = grid.getRow(index);
			toolbarAdd({
				title:"编辑会员资料",
				width:800,
				folderName:"gift.21-sun.com/gift_member_payoff",
				fileName:"gift_member_payoff",
				height:350
			},row.uuid);
    	}
    }
    
    function viewOrders(rowIndex){
		var row = grid.getRow(rowIndex);
		toolbarAdd({
			width:1000,
			height:500,
			folderName:"gift.21-sun.com/gift_member_payoff",
			fileName:"gift_order",
			params:{
				payoff_no:row.payoff_no
			},
			title:"查看" + row.mem_no + "提现的订单"
		});
	}
</script>